filename = 'test.txt'
try:
    f = open(filename, 'r')
except FileNotFoundError as e:
    print(e)
    f = open(filename, 'w')
else:
    print('文件存在且已打开')
finally:
    print('文件关闭')
    f.close()
